<?php
 session_start();
 require_once "conn.php";

 $vranswer = array();
 mysql_query("SET CHARACTER SET utf8");
 for ($i=1; $i<=10; $i++) {
  $vrsql = mysql_query("SELECT * FROM tbquiz WHERE id = '".$_SESSION["questions"]["q"][$i]."'") or die(mysql_eerno().': '.mysql_error());
  while($vrdata = mysql_fetch_array($vrsql))
  {
   $vrquestion[$i] = $vrdata["question"];
   $vra[$i] = $vrdata["a"];
   $vrb[$i] = $vrdata["b"];
   $vrc[$i] = $vrdata["c"];
   $vrd[$i] = $vrdata["d"];
   $vre[$i] = $vrdata["e"];
   $vranswer[$i] = $vrdata["answer"];
  }
 }
 
 $correct = 0;
 $incorrect = 0;
 for ($x=1; $x<=10; $x++) {
  if ($vranswer[$x] == $_SESSION["questions"]["a"][$x]) {
   echo "$x) correto! resposta: $vranswer[$x]<br/>";
   echo "<a id=\"link$x\" href=\"javascript:toggle('link$x','text$x');\">pergunta</a><br />";
   echo "<div id=\"text$x\" style=\"display:none\">";
   echo $vrquestion[$x]."<br />";
   echo "a) ".$vra[$x]."<br />";
   echo "b) ".$vrb[$x]."<br />";
   echo "c) ".$vrc[$x]."<br />";
   echo "d) ".$vrd[$x]."<br />";
   echo "e) ".$vre[$x]."<br /><br />";
   echo "</div>";
   $correct++;
  }
  else {
   echo "$x) incorreto! resposta: $vranswer[$x]<br/>";
   echo "<a id=\"link$x\" href=\"javascript:toggle('link$x','text$x');\">pergunta</a><br />";
   echo "<div id=\"text$x\" style=\"display:none\">";
   echo $vrquestion[$x]."<br />";
   echo "a) ".$vra[$x]."<br />";
   echo "b) ".$vrb[$x]."<br />";
   echo "c) ".$vrc[$x]."<br />";
   echo "d) ".$vrd[$x]."<br />";
   echo "e) ".$vre[$x]."<br /><br />";
   echo "</div>";
   $incorrect++;
  }  
 }
 echo "Voc&ecirc; acertou $correct  de 10.<br /><br /><br />";
 echo "<a href=\"index.php\">retornar</a>";
?>
